package com.dyz.leetcode._02_string;

public class _28_strStr {
    //KMP算法
    public int strStr(String haystack, String needle) {
        int h = haystack.length();
        int n = needle.length();


        return -1;
    }
    //暴力解法
    public int strStr1(String haystack, String needle) {
        int h = haystack.length();
        int n = needle.length();

        for(int i=0; i+n<=h; i++){
            boolean flag = true;
            for(int j=0; j<n; j++){
                if(haystack.charAt(i+j)!=needle.charAt(j)){
                    flag=false;
                    break;
                }
            }
            if(flag){
                return i;
            }
        }
        return -1;
    }

}
